package com.moonshineproject.plugin.haxe.haxeproject.vo
{
	import com.moonshineproject.utils.Utils;
	
	public class HaxeBuildOptions
	{
		public var directives:String = "";
		public var flashStrict:Boolean;
		public var mainClass:String;
		public var overRide:Boolean;
		public var verbose:Boolean;
		public var additional:String = "";
		
		
		public function parse(build:XMLList):void 
		{
			var options:XMLList = build.option;
			
			directives							= Utils.deserializeString(options.@directives);
			flashStrict							= Utils.deserializeBoolean(options.@flashStrict);
			verbose								= Utils.deserializeBoolean(options.@verbose);
			mainClass							= Utils.deserializeString(options.@mainClass);
			additional							= Utils.deserializeString(options.@additional);
			overRide 							= Utils.deserializeBoolean(options.attribute('override'));
		}
		
		public function toXML():XML
		{
			var build:XML = <build/>;
			
			var pairs:Object = {
    			directives	: Utils.serializeString(directives),
    			flashStrict	: Utils.serializeBoolean(flashStrict),
    			mainClass	: Utils.serializeString(mainClass),
    			override	: Utils.serializeBoolean(overRide),
    			verbose		: Utils.serializeBoolean(verbose),
    			additional	: Utils.serializeString(additional)
			}
			
			build.appendChild(Utils.serializePairs(pairs, <option/>));
			
			return build;
		}
		
	}
}